home *** CD-ROM | disk | FTP | other *** search
/ ftp.whtech.com / ftp.whtech.com.tar / ftp.whtech.com / utilities / Myarc FDC 18 sectors per track.txt < prev    next >
Text File  |  2006-10-19  |  9KB  |  230 lines

  1.  
  2. * Myarc FDC 18 sectors/track DSDD format routine
  3. * Original code by Will McGovern 
  4. * More or less as used in Funnelweb DiskReview 
  5. *  and earlier DM-1000 upgrade
  6. * Self-contained but assumes VMBR, VMBW utilities
  7. *  available in calling program
  8. *  - otherwise write your own as in-line code
  9. * Easily modified for DSQD - just change track count 
  10. * Self-modifying for drive select SBO instruction at
  11. *  label MYFMT3 - needs change for use as ROM code 
  12.  
  13. *--- Call as ---
  14. * BLWP @MYFMT
  15. * BYTE drive#(1-4),#sides(1-2)
  16. * JMP  ERROR
  17. *-----------
  18.  
  19. MPAD   EQU  >8300            PAD fast memory
  20. MGPLWS EQU  >83E0            Fast WSP for critical code
  21. MBUFFR EQU  >DF80            Temp track layout buffer
  22. TRKLEN EQU  >1830            Nominal (min) size of track
  23. PADSAV EQU  >3600            Temp VDP save area for PAD   
  24.  
  25. *  Data for track and sectors
  26. *  Byte/count table
  27. *  >156 bytes for each sector data block
  28.  
  29. FMTDTA BYTE >4E,>28          Track lead in 
  30. FMTDTB BYTE >00,>0C          Synchronize for address
  31.        BYTE >F5,>03          MFM filler
  32.        BYTE >FE,>01          Address mark
  33.        BYTE >00,>03          Data to be filled in
  34.        BYTE >01,>01          256 byte sectors
  35.        BYTE >F7,>01          For CRC generation
  36.        BYTE >4E,>18          Filler - ID/Data separation
  37.        BYTE >00,>0C          Synchronize for data 
  38.        BYTE >F5,>03          MFM filler
  39.        BYTE >FB,>01          Data mark
  40.        BYTE >E5,>80,>E5,>80  Initialized sector data
  41.        BYTE >F7,>01          For CRC generation
  42.        BYTE >4E,>18          Filler
  43. MBAA   BYTE >AA              Flag for end of sector data
  44. MSCTLN EQU  >156             Sector data length
  45.  
  46. *  FDC command and misc data 
  47.  
  48. T0     BYTE >02              Restore to track #0 command
  49. SI     BYTE >52              Step head in command
  50. WT     BYTE >F0              Write track command
  51. MFOUR  BYTE >04              Max # drives
  52.  
  53. *  Sector interlace table
  54.  
  55. INTLCE BYTE 0,11,4,15,8,1,12,5,16
  56.        BYTE 9,2,13,6,17,10,3,14,7
  57.        EVEN
  58.  
  59. MYFWSP BSS  >20              Workspace in RAM 
  60.  
  61. *  Format code BLWP entry point
  62.  
  63. MYFMT  DATA MYFWSP,MYFMT1    BLWP vector  
  64.  
  65. MYFMT1 MOVB *R14,*R14        Check drive #
  66.        JEQ  BADDRV           Don't use this routine
  67.        CB   *R14,@MFOUR      Max 4 drives permitted 
  68.        JLE  MYFT1A           OK
  69. BADDRV RTWP                  Immediate error return
  70.  
  71. MYFT1A LI   R0,PADSAV        Save contents of PAD to VDP
  72.        LI   R1,MPAD          PAD RAM
  73.        LI   R2,>0100         Do the lot for simplicity
  74.        BLWP @VMBW            Assumed available 
  75.        LI   R0,MCODE         Code for writing to disk  
  76.        LI   R1,MPAD          Put in PAD for speed
  77. MYFMT2 MOV  *R0+,*R1+        Copy it over
  78.        JNE  MYFMT2           Data is null word terminated 
  79.  
  80. *  Construct track data
  81.  
  82. MYFMT4 LI   R2,MBUFFR        Point to track buffer 
  83.        LI   R3,18            18 sectors/track
  84.        LI   R4,FMTDTA        Track data table byte/count
  85.        JMP  MYFMT7           Include track lead in
  86. MYFMT6 LI   R4,FMTDTB        Data table for each sector
  87. MYFMT7 MOVB *R4+,R0          Fetch data-byte
  88.        CB   @MBAA,R0         End marker byte ?
  89.        JNE  MYFMT8           No - go write in repeats
  90.        DEC  R3               Count off sectors
  91.        JNE  MYFMT6           More to do
  92.        JMP  MYFM10           Track layout done
  93.  
  94. MYFMT8 MOVB *R4+,R1          Fetch repeat byte-count
  95.        SRL  R1,8             Make word count 
  96. MYFMT9 MOVB R0,*R2+          Write to buffer
  97.        DEC  R1               Tick off
  98.        JNE  MYFMT9           Next repeat of byte
  99.        JMP  MYFMT7           Go get next data-byte
  100.  
  101. *  Set up FDC for track write
  102.  
  103. MYFM10 MOVB *R14+,R0         Fetch drive # 
  104.        AI   R0,>300          Massage for CRU drive select
  105.        MOVB R0,@MYFMT3+1     Write in to CRU instruction 
  106.        MOVB *R14+,R5         Fetch # of sides
  107.        SRL  R5,8             Make word
  108.        CLR  R6               For side 1 - first pass
  109.        LI   R12,>1100        Select FDC DSR CRU base  
  110.        LDCR @MNULL,8         Make sure all reset
  111.        SBO  0                Turn on DSR
  112.        SBO  1                Turn on FDC controller
  113. MYFMT3 SBO  0                Drive CRU # written to LSB
  114.        SBZ  2                
  115.        SBZ  3
  116. RSTORE BL   @TRK00           Reset to Track #0 
  117.        JMP  MSKERR           Error exit
  118.  
  119. *  Write interlace pattern into track data
  120.  
  121. MYFM11 LI   R3,40            Tracks/side (80 for 720 Kb)
  122.        CLR  R4               Initialize track #
  123. MYFM12 LI   R0,MBUFFR+>38    First sector ID pointer
  124.        LI   R1,18            Sectors/track count
  125.        LI   R2,INTLCE        Sector interlace pattern  
  126. MYFM13 MOVB R4,*R0+          Track #
  127.        MOVB R6,*R0+          Side # 
  128.        MOVB *R2+,*R0         Sector #
  129.        AI   R0,MSCTLN-2      Next sector ID
  130.        DEC  R1               Count off sector
  131.        JNE  MYFM13           More to do
  132.  
  133.        BLWP @WRTTRK          Write the track to disk
  134.        JMP  WTERR2           Error return
  135.        DEC  R3               Count off a track
  136.        JEQ  MYFM14           Done 
  137.        BL   @STEP            Step in one track
  138.        JMP  MSKERR           Error return
  139.        AI   R4,>100          Next track #
  140.        JMP  MYFM12           Set up next track data 
  141.  
  142. MYFM14 AI   R6,>100          For disk side 2
  143.        SBO  2                Disk side #2 if needed 
  144.        DEC  R5               Done ?
  145.        JNE  RSTORE           Second side to go      
  146.        INCT R14              Step over error return
  147.  
  148. *  Restore PAD and exit
  149.  
  150. WTERR2  EQU  $               Error return
  151. MSKERR  EQU  $
  152.         LDCR @MNULL,8        Turn it all off
  153.         LI   R0,PADSAV       VDP buffer
  154.         LI   R1,MPAD         Set up to restore PAD
  155.         LI   R2,>100         Retrieve whole PAD
  156.         BLWP @VMBR           Utility assumed available
  157.         RTWP                 Back to main program
  158.  
  159. *  Direct track writing code
  160. *  Timing critical - code and workspace both in PAD
  161. *  >5F01 is Myarc memory mapped control register address 
  162. *  >5F07 is Myarc memory mapped write register address
  163.  
  164. WRTTRK DATA MGPLWS,WRTTK1    Use GPL Workspace in PAD
  165. WRTTK1 LI   R4,>5F07         FDC write address in register
  166.        LI   R5,MBUFFR        Track data in RAM 
  167.        LI   R6,TRKLEN        Size of track data
  168.        LI   R7,>4E4E         Track run-out byte
  169.        LI   R12,>1100        FDC CRU base
  170.        SETO R0               Set time-out counter
  171.        MOVB @WT,@>5F01       Send WRITE command to FDC 
  172.        BL   @MPAD            BL to MCODE code in PAD
  173.        INCT R14              Step over error return
  174.        RTWP                  Directly here after error
  175.  
  176. * Code block to be moved to PAD for speed
  177.  
  178. MCODE  EQU  $                Start fast code for PAD
  179.        TB   1                Want to write
  180.        JEQ  MCODE4           Yeah, go ahead
  181.        DEC  R0               One more time
  182.        JEQ  MCODE2           That's it - return an error
  183.        TB   1                Ask again to write
  184.        JEQ  MCODE4           Ready now
  185.        TB   0                Check INTRQ
  186.        JNE  MCODE            No, not yet 
  187. MCODE2 RT   
  188.  
  189. MCODE3 TB   1                Want to write again
  190.        JNE  MCODE3           Wait for it
  191. MCODE4 MOVB *R5+,*R4         Write a byte to the FDC
  192.        DEC  R6               Count it off
  193.        JNE  MCODE3           More to go
  194. MCODE5 MOVB R7,*R4           Run-out track to end
  195.        TB   0                Check INTRQ
  196.        JNE  MCODE5           Not done yet
  197.        INCT R11              Step over error return
  198.        RT
  199. MNULL  DATA 0                Null flag ends copy to PAD
  200.  
  201. *-------
  202. *  Head control subroutines with error branch
  203. *  Call as                                                        *  BL  
  204. @TRK00  - Restore head to track #0
  205. *  BL   @STEP   - Step head in one track
  206. *  JMP  ERR     <- seek/drive error
  207. *----------
  208.  
  209. TRK00  MOVB @T0,@>5F01       Send RESTORE command to FDC
  210.        JMP  INTRQ
  211. STEP   MOVB @SI,@>5F01       Send STEP-IN command to FDC
  212. INTRQ  LI   R1,2             Set outside loop counter 
  213. INTRQ1 SETO R0               Set error counter
  214. INTRQ2 TB   0                INTRQ ?       
  215.        JEQ  INTRQ3           Yes - exit normally
  216.        DEC  R0               Inner loop run out ?
  217.        JNE  INTRQ2           No - keep waiting
  218.        DEC  R1               Yes - outer loop done ?
  219.        JNE  INTRQ1           No - reset inner loop
  220.        JMP  INTRQ4           Yes - exit with error
  221. INTRQ3 INCT R11              Step over error JMP
  222. INTRQ4 RT      
  223.  
  224.  
  225.  
  226.  
  227. -- 
  228. -----------------------------------------------------------
  229. arvcm@cc.newcastle.edu.au
  230. -----------------------------------------------------------